<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>医生管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../js/layui/css/layui.css"  media="all">
	<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
  
</head>
<body>
 
<table class="layui-hide" id="test" lay-filter="test"></table>

<!-- <script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm" lay-event="add_admin">添加管理员</button>
  </div>
</script> -->
 
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
              
          
<script src="../js/layui/layui.js" charset="utf-8"></script>
 
<script>
layui.use(['table','layer'], function(){
  var table = layui.table,
	layer = layui.layer;
  
  table.render({
    elem: '#test'
    ,url:'../static/admin_Doc_info.json'
    ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
    ,defaultToolbar: ['filter', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
      title: '提示'
      ,layEvent: 'LAYTABLE_TIPS'
      ,icon: 'layui-icon-tips'
    }]
    ,title: '用户数据表'
    ,cols: [[
      {type: 'checkbox', fixed: 'left'}
     ,{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
     ,{field: 'username', title: '医生姓名', width:120}
     ,{field: 'hospital', title: '所属机构', width:120}
     ,{field: 'professional', title: '专科医生', width:120} 
     ,{field: 'sign_people', title: '签约人数', width: 120}
     ,{field: 'Doc_phone', title: '电话', width: 120}
     ,{field: 'classify', title: '职称', width: 120}
      ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
    ]]
		,page : true
		
  });
	
						
  //头工具栏事件
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    switch(obj.event){
    //   case 'add_admin':
    //     //layer.msg('添加管理员');
				// layer.open({
				// 	type: 1,
				// 	title:"添加管理员",
				// 	area: ['420px', '330px'],
				// 	content: $('#popUpdateTest')
				// })
				
    //   break;
      
      //自定义头工具栏右侧图标 - 提示
      case 'LAYTABLE_TIPS':
        layer.alert('有问题请咨询售后工程师');
      break;
    };
  });
  
  //监听行工具事件
  table.on('tool(test)', function(obj){
    var data = obj.data;
    //console.log(obj)
    if(obj.event === 'del'){
      layer.confirm('真的删除该名家庭医生吗？', function(index){
				console.log(data.phone);
				obj.del();
				layer.close(index);
         $.ajax({
            url: "",
            type: "POST",
            data: {name: data.phone},
            success: function (msg) {
            var json = JSON.parse(msg);
            var returnCode = json.returnCode;
            if (returnCode == 200) {
								//删除这一行
							obj.del();
								//关闭弹框
              layer.close(index);
              layer.msg("删除成功", {icon: 6});
							} else {
                layer.msg("删除失败", {icon: 5});
              }
						}
					});
				return false;
      });
    } 
		// else if(obj.event === 'edit'){
  //     layer.prompt({
  //       formType: 2
  //       ,value: data.email
  //     }, function(value, index){
  //       obj.update({
  //         email: value
  //       });
  //       layer.close(index);
  //     });
  //   }
  });
});
</script>

<!-- 弹出层 添加管理员-->
<div class="layui-row" id="popUpdateTest" style="display:none;">
    <div class="layui-col-md10">
        <form class="layui-form layui-from-pane" action="" style="margin-top:20px" >
            <div class="layui-form-item">
                <label class="layui-form-label">账号名</label>
                <div class="layui-input-block">
                    <input type="text" name="new_admin"  required  lay-verify="required" autocomplete="off" placeholder="账号名" class="layui-input">
                </div>
            </div>
						<div class="layui-form-item">
						    <label class="layui-form-label">电话</label>
						    <div class="layui-input-block">
						        <input type="text" name="admin_phone"  required  lay-verify="required" autocomplete="off" placeholder="电话" class="layui-input">
						    </div>
						</div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="pass"  required  lay-verify="required" autocomplete="off" placeholder="密码" class="layui-input">
                </div>
            </div>
						<div class="layui-form-item">
						    <label class="layui-form-label">确认密码</label>
						    <div class="layui-input-block">
						        <input type="password" name="pass2"  required  lay-verify="required" autocomplete="off" placeholder="密码" class="layui-input">
						    </div>
						</div>
            <div class="layui-form-item" style="margin-top:40px">
                <div class="layui-input-block">
                    <button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="demo11">确认修改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

</body>
</html>